package com.wdd.libarouter.impl

import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.facade.service.SerializationService
import com.blankj.utilcode.util.GsonUtils
import com.blankj.utilcode.util.LogUtils
import com.wdd.libarouter.config.ArouterPathConfig
import java.lang.reflect.Type

/**
 *
 * @ProjectName:    OwnTool
 * @Package:        com.wdd.libarouter.impl
 * @ClassName:      JsonServiceImpl
 * @Description:    Apu
 * @Author:         王丹丹
 * @CreateDate:     2019/12/2 17:55
 * @UpdateUser:     更新者
 * @UpdateDate:     2019/12/2 17:55
 * @UpdateRemark:   更新说明
 * @Version:        1.0
 */
@Route(path = ArouterPathConfig.JSON_CONVERT_PATH)
class JsonServiceImpl : SerializationService {
    override fun init(context: Context?) {

    }

    override fun <T : Any?> json2Object(input: String?, clazz: Class<T>?): T {
        LogUtils.d("转数据到str333")
        return GsonUtils.getGson().fromJson(input, clazz)
    }


    override fun object2Json(instance: Any?): String {
        return GsonUtils.getGson().toJson(instance)
    }

    override fun <T : Any?> parseObject(input: String?, clazz: Type?): T {
        return GsonUtils.getGson().fromJson(input, clazz)
    }

}